package com.zhangmeng.tools.utils;

import io.minio.MinioClient;
import io.minio.errors.*;
import io.minio.messages.Bucket;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * @author : 芊芊墨客
 * @version : 1.0
 * @date : 2023-04-27 17:49
 */
public class Test {
    public static void main(String[] args) {
        String endpoint = "http://123.57.75.116:49002";
        String accessKey = "admin";
        String secretKey = "password";
        MinioClient minioClient = MinioClient.builder().endpoint(endpoint.toString()).credentials(accessKey.toString(), secretKey.toString()).build();
        System.out.println(minioClient);
        try {
            List<Bucket> allBuckets = minioClient.listBuckets();
            for (Bucket bucket : allBuckets) {
                System.out.println(bucket.name());
            }


        } catch (ErrorResponseException e) {
            e.printStackTrace();
        } catch (InsufficientDataException e) {
            e.printStackTrace();
        } catch (InternalException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        } catch (InvalidResponseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (XmlParserException e) {
            e.printStackTrace();
        }

    }
}
